﻿using System;

namespace Basmus.Values
{
    public class ModelContext
    {
        public ModelContext(Type targetType, SchemeKey schemeKey)
        {
            TargetType = targetType;
            SchemeKey = schemeKey;
        }

        public Type TargetType { get;private set; }

        public SchemeKey SchemeKey { get; private set; }

        public ValuesContext CreateValueContext(string name)
        {
            return new ValuesContext(this, name);
        }

        public bool Equals(ModelContext other)
        {
            var result = TargetType == other.TargetType && SchemeKey == other.SchemeKey;
            return result;
        }

        public override int GetHashCode()
        {
            return TargetType.GetHashCode() ^ SchemeKey.GetHashCode();
        }

        public override bool Equals(object obj)
        {
            return Equals((ModelContext)obj);
        }

        public static bool operator ==(ModelContext a, ModelContext b)
        {
            return a.Equals(b);
        }

        public static bool operator !=(ModelContext a, ModelContext b)
        {
            return !(a == b);
        }
    }
}
